package com.lishe.lishe.lishe.bean;


import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import com.lishe.lishe.lishe.module.myorder.bean.BusinessObject;
import com.lishe.lishe.lishe.module.myorder.bean.GoodObject;


/**
 * Created by lwa on 2017/9/6.
 */

public class ShoppingCartObject implements Serializable {
    /**
     * 购物车所有商品的总金额
     */
    private double shoppingCartTotalMoney;
    /**
     * 购物车选中商品的总金额
     */
    private int goodsCount = 0;//所有商品数
    private boolean isCheck = false;
    private int checkGoodsCount = 0;//选中商品数

    public int getGoodsCount() {
        goodsCount = 0;
        for (int i = 0; i < lisBusinessObject.size(); i++) {
            BusinessObject businessObject = lisBusinessObject.get(i);
            goodsCount += businessObject.getTradeData().getOrderList().size();
        }
        return goodsCount;
    }

    public void setGoodsCount(int goodsCount) {
        this.goodsCount = goodsCount;
    }

    private List<BusinessObject> lisBusinessObject = new ArrayList<>();

    public List<BusinessObject> getLisBusinessObject() {
        return lisBusinessObject;
    }

    public void setLisBusinessObject(List<BusinessObject> lisBusinessObject) {
        this.lisBusinessObject = lisBusinessObject;
    }

    public double getShoppingCartTotalMoney() {
        return shoppingCartTotalMoney;
    }

    public void setShoppingCartTotalMoney(double shoppingCartTotalMoney) {
        this.shoppingCartTotalMoney = shoppingCartTotalMoney;
    }

    DecimalFormat df  = new DecimalFormat("######0.00");
    public double getPayMoney() {
        double payMoney = 0;
        for (BusinessObject businessObject : lisBusinessObject) {
            for (GoodObject goodObject : businessObject.getTradeData().getOrderList()) {
                if (goodObject.isCheck()) {
                    payMoney = payMoney + (Double.parseDouble(goodObject.getPrice()) * (double) goodObject.getNum());
                }
            }
        }
        return payMoney;
    }

    public int getCheckGoodsCount() {
        checkGoodsCount = 0;
        for (BusinessObject businessObject : lisBusinessObject) {
            checkGoodsCount = checkGoodsCount + businessObject.getCheckGoodsCount();
        }
        return checkGoodsCount;
    }

//    public void setCheckGoodsCount(int checkGoodsCount) {
//        this.checkGoodsCount = checkGoodsCount;
//    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }
//    public void setPayMoney(double payMoney) {
//        this.payMoney = payMoney;
//    }
}
